pandas 1.4.2

NotesParametersReturns
f(self, other, axis='columns', level=None)

Among flexible wrappers (:None:None:`eq`, :None:None:`ne`, :None:None:`le`, :None:None:`lt`, :None:None:`ge`, :None:None:`gt`) to comparison operators.

Equivalent to :None:None:`==`, :None:None:`!=`, :None:None:`<=`, :None:None:`<`, :None:None:`>=`, :None:None:`>` with support to choose axis (rows or columns) and level for comparison.

Notes

Mismatched indices will be unioned together. NaN values are considered different (i.e. NaN != NaN ).

Parameters

other : scalar, sequence, Series, or DataFrame

Any single or multiple element data structure, or list-like object.

axis : {0 or 'index', 1 or 'columns'}, default 'columns'

Whether to compare by the index (0 or 'index') or columns (1 or 'columns').

level : int or label

Broadcast across a level, matching Index values on the passed MultiIndex level.

Returns

DataFrame of bool

Result of the comparison.

Get Greater than or equal to of dataframe and other, element-wise (binary operator :None:None:`ge`).

See Also

DataFrame.eq

Compare DataFrames for equality elementwise.

DataFrame.ge

Compare DataFrames for greater than inequality or equality elementwise.

DataFrame.gt

Compare DataFrames for strictly greater than inequality elementwise.

DataFrame.le

Compare DataFrames for less than inequality or equality elementwise.

DataFrame.lt

Compare DataFrames for strictly less than inequality elementwise.

DataFrame.ne

Compare DataFrames for inequality elementwise.

Examples

This example is valid syntax, but we were not able to check execution
>>> df = pd.DataFrame({'cost': [250, 150, 100],
...  'revenue': [100, 250, 300]},
...  index=['A', 'B', 'C'])
... df cost revenue A 250 100 B 150 250 C 100 300

Comparison with a scalar, using either the operator or method:

This example is valid syntax, but we were not able to check execution
>>> df == 100
    cost  revenue
A  False     True
B  False    False
C   True    False
This example is valid syntax, but we were not able to check execution
>>> df.eq(100)
    cost  revenue
A  False     True
B  False    False
C   True    False

When other is a Series , the columns of a DataFrame are aligned with the index of other and broadcast:

This example is valid syntax, but we were not able to check execution
>>> df != pd.Series([100, 250], index=["cost", "revenue"])
    cost  revenue
A   True     True
B   True    False
C  False     True

Use the method to control the broadcast axis:

This example is valid syntax, but we were not able to check execution
>>> df.ne(pd.Series([100, 300], index=["A", "D"]), axis='index')
   cost  revenue
A  True    False
B  True     True
C  True     True
D  True     True

When comparing to an arbitrary sequence, the number of columns must match the number elements in other :

This example is valid syntax, but we were not able to check execution
>>> df == [250, 100]
    cost  revenue
A   True     True
B  False    False
C  False    False

Use the method to control the axis:

This example is valid syntax, but we were not able to check execution
>>> df.eq([250, 250, 100], axis='index')
    cost  revenue
A   True    False
B  False     True
C   True    False

Compare to a DataFrame of different shape.

This example is valid syntax, but we were not able to check execution
>>> other = pd.DataFrame({'revenue': [300, 250, 100, 150]},
...  index=['A', 'B', 'C', 'D'])
... other revenue A 300 B 250 C 100 D 150
This example is valid syntax, but we were not able to check execution
>>> df.gt(other)
    cost  revenue
A  False    False
B  False    False
C  False     True
D  False    False

Compare to a MultiIndex by level.

This example is valid syntax, but we were not able to check execution
>>> df_multindex = pd.DataFrame({'cost': [250, 150, 100, 150, 300, 220],
...  'revenue': [100, 250, 300, 200, 175, 225]},
...  index=[['Q1', 'Q1', 'Q1', 'Q2', 'Q2', 'Q2'],
...  ['A', 'B', 'C', 'A', 'B', 'C']])
... df_multindex cost revenue Q1 A 250 100 B 150 250 C 100 300 Q2 A 150 200 B 300 175 C 220 225
This example is valid syntax, but we were not able to check execution
>>> df.le(df_multindex, level=1)
       cost  revenue
Q1 A   True     True
   B   True     True
   C   True     True
Q2 A  False     True
   B   True    False
   C   True    False
See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /pandas/core/ops/__init__.py#464
type: <class 'function'>
Commit: